package com.github.baichuan.application.scaffold.jpa.identity;

import com.github.baichuan.application.scaffold.domain.application.Realm;
import com.github.baichuan.application.scaffold.domain.identity.Member;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface MemberRepository extends JpaRepository<Member, String>, JpaSpecificationExecutor<Member> {

    @Query(value = "select m from Member m where realm=:realm and loginName=:loginName")
    Optional<Member> find(@Param("realm") Realm realm, @Param("loginName") String loginName);

    Optional<Member> findByDingUnionId(String dingUnionId);
}
